using System;
using System.Collections.Generic;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

using HadronData;

namespace Hadron.SpecialEffects
{
    class ProjectileBlast
        : SpecialEffect
    {
        private ParticleSystem m_particleSystem;

        public ProjectileBlast(Environment p_environment, Vector2 p_vecPosition, Color p_colour)
        {
            m_particleSystem = new ParticleSystem(16, 0.0f, 1.0f);
            m_particleSystem.Position = p_vecPosition;
            m_particleSystem.ParticleColours = new Color[] { p_colour, Color.Black };
            m_particleSystem.EmissionVelocityVariance = 48.0f;
            m_particleSystem.EmitBatch(16);
            m_fLifetime = 1.0f;

            AssetManager.Sounds.ProjectileHit.Play(p_environment.ComputeSoundVolume(p_vecPosition));
        }

        public ParticleSystem ParticleSystem
        {
            get { return m_particleSystem; }
        }

        public override void Update(GameTime p_gameTime)
        {
            m_particleSystem.Update(p_gameTime);

            float fDeltaTime = (float)p_gameTime.ElapsedGameTime.TotalSeconds;
            m_fLifetime -= fDeltaTime;
        }

        public override void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch p_spriteBatch)
        {
            m_particleSystem.Draw(p_spriteBatch);
        }
    }
}
